package com.test.group.plugin.demo.window.action;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageDialogBuilder;
import com.intellij.openapi.ui.Messages;

/**
 * 一个弹窗提醒测试
 * @author tianfeng
 */
public class AlertAction extends AnAction {

    @Override
    public void actionPerformed(AnActionEvent e) {
        Project project = e.getProject();

        // 1. 使用 Messages 对象创建一个提示弹框
        Messages.showInfoMessage("Hi 你好 IDEA", "提醒");
        int i = Messages.showDialog("Hi 你好 IDEA", "提醒", new String[]{"Option one", "Option two"}, 0, Messages.getErrorIcon());
        String password = Messages.showPasswordDialog("这个是一个输入提示窗，上一步输入结果：" + i, "密码提示");

        // 2. 使用 MessageDialogBuilder 对象创建一个提示弹窗
        MessageDialogBuilder.yesNo("操作结果", "添加成功");
        MessageDialogBuilder.okCancel("确认提醒", "是否确认" + password).ask(project);
    }

}
